﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace Thurn_und_Taxis.components
{
    /// <summary>
    /// Interaction logic for RoomBox.xaml
    /// </summary>
    public partial class RoomBox : UserControl
    {
        public RoomBox()
        {
            InitializeComponent();
        }

        public void SetPlayer1(String nickname)
        {
            labelPlayer1.Visibility = Visibility.Visible;
            labelPlayer1.Content = nickname;
        }
        public void SetPlayer2(String nickname)
        {
            labelPlayer2.Visibility = Visibility.Visible;
            labelPlayer2.Content = nickname;
        }
        public void SetPlayer3(String nickname)
        {
            labelPlayer3.Visibility = Visibility.Visible;
            labelPlayer3.Content = nickname;
        }
        public void SetPlayer4(String nickname)
        {
            labelPlayer4.Visibility = Visibility.Visible;
            labelPlayer4.Content = nickname;
        }
        public void SetRoomName(String roomId)
        {            
            labelRoomName.Content = roomId;
        }
        public void SetStarted(Boolean isStarted)
        {
            String sourceFile;

            if (isStarted)
                sourceFile = "resources/images/stop.png";
            else
                sourceFile = "resources/images/join.png";

            Stream imageStreamSource = new FileStream(sourceFile, FileMode.Open, FileAccess.Read, FileShare.Read);
            PngBitmapDecoder decoder = new PngBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            BitmapSource bitmapSource = decoder.Frames[0];

            imageClosed.Source = bitmapSource;
        }
    }
}
